﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Http.Routing;
using TjZheng.Framework;
using TjZheng.Power.Business;

namespace TjZheng.WebApi.Test.Controllers
{
    public class ValuesController : TjZhengApiController
    {
        //[MyActionFilter]
        // GET api/values
        public IEnumerable<string> Get(string name)
        {
            string str = string.Format("{0}{1}");
            return new string[] { "value1", "value2" };
        }

        //public IEnumerable<string> Get(string name)
        //{
        //    //string str = string.Format("{0}{1}");
        //    return new string[] { "value1", "value2" };
        //}

        //public InvokeResult Get(string name)
        //{
        //    return new InvokeResult();
        //}

        //public IEnumerable<TjZheng.Power.DataEntity.UserInfo> Get(string name)
        //{
        //    return new BizUserInfo().GetList("");
        //}

        // GET api/values/5
        public string Get(int id, string name)
        {
            return "value";
        }

        // POST api/values
        public Person Post([FromBody]Person objPerson, [FromUri]string name1, int id)
        {
            return objPerson;
        }

        // PUT api/values/5
        public Person Put(int id, [FromBody]string value)
        {
            return new Person { Name = value, Age = id };
        }

        // DELETE api/values/5
        public string Delete(int id)
        {
            return "ValuesController.Delete(int id)";
        }

        public Person GetPerson(string name, int age)
        {
            return new Person { Name = name, Age = age };
        }
        public Person PostPerson([FromBody]Person objPerson, int id)
        {
            return objPerson;
        }

        [HttpGet]
        public string Process(HttpRequestMessage request, string para)
        {
            return request.GetRouteData().Values["controller"].ToString();
        }
    }

    public class Person
    {
        public string Name { get; set; }
        public int Age { get; set; }
    }
}